Fixup SMCCC_FEATURES return value for SMCCC_ARCH_WORKAROUND_1
authorDimitris Papastamos <[email protected]>
Wed, 28 Mar 2018 11:06:40 +0000 (12:06 +0100)
committerDimitris Papastamos <[email protected]>
Tue, 3 Apr 2018 15:34:12 +0000 (16:34 +0100)
Only return -1 if the workaround for CVE-2017-5715 is not compiled in.

Change-Id: I1bd07c57d22b4a13cf51b35be141a1f1ffb065ff
Signed-off-by: Dimitris Papastamos <[email protected]>
docs/cpu-specific-build-macros.rst
services/arm_arch_svc/arm_arch_svc_setup.c

index 9e11cdff6cd5feb98dfc82ebb3bf72e2ed938cab..65f6adb8d18730e0f68536f11d0f405f787e87a0 100644 (file)
@@ -18,7 +18,11 @@ TF-A exports a series of build flags which control which security
 vulnerability workarounds should be applied at runtime.
 
 -  ``WORKAROUND_CVE_2017_5715``: Enables the security workaround for
-   `CVE-2017-5715`_. Defaults to 1.
+   `CVE-2017-5715`_. This flag can be set to 0 by the platform if none
+   of the PEs in the system need the workaround. Setting this flag to 0 provides
+   no performance benefit for non-affected platforms, it just helps to comply
+   with the recommendation in the spec regarding workaround discovery.
+   Defaults to 1.
 
 CPU Errata Workarounds
 ----------------------
index 83d3625f958d509ecfcb131479b72ebfbec95339..eb736c060e4647a46b3046aee7e44df76c1f86bc 100644 (file)
@@ -19,19 +19,16 @@ static int32_t smccc_version(void)
 
 static int32_t smccc_arch_features(u_register_t arg)
 {
-       int ret;
-
        switch (arg) {
        case SMCCC_VERSION:
        case SMCCC_ARCH_FEATURES:
                return SMC_OK;
+#if WORKAROUND_CVE_2017_5715
        case SMCCC_ARCH_WORKAROUND_1:
-               ret = check_workaround_cve_2017_5715();
-               if (ret == ERRATA_APPLIES)
-                       return 0;
-               else if (ret == ERRATA_NOT_APPLIES)
+               if (check_workaround_cve_2017_5715() == ERRATA_NOT_APPLIES)
                        return 1;
-               return -1; /* ERRATA_MISSING */
+               return 0; /* ERRATA_APPLIES || ERRATA_MISSING */
+#endif
        default:
                return SMC_UNK;
        }